/*******************************************************************************
 *
 * Pentaho Big Data
 *
 * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.pentaho.runtime.test.result.org.pentaho.runtime.test.result.impl;

import org.pentaho.runtime.test.result.RuntimeTestResultEntry;
import org.pentaho.runtime.test.result.RuntimeTestResultSummary;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by bryan on 8/26/15.
 */
public class RuntimeTestResultSummaryImpl implements RuntimeTestResultSummary {
  private final RuntimeTestResultEntry rollupTestResultEntry;
  private final List<RuntimeTestResultEntry> runtimeTestResultEntries;

  public RuntimeTestResultSummaryImpl() {
    this( null );
  }

  @SuppressWarnings( "unchecked" )
  public RuntimeTestResultSummaryImpl( RuntimeTestResultEntry rollupTestResultEntry ) {
    this( rollupTestResultEntry, Collections.EMPTY_LIST );
  }

  public RuntimeTestResultSummaryImpl( RuntimeTestResultEntry rollupTestResultEntry,
                                       List<RuntimeTestResultEntry> runtimeTestResultEntries ) {
    this.rollupTestResultEntry = rollupTestResultEntry;
    this.runtimeTestResultEntries = Collections.unmodifiableList( new ArrayList<>( runtimeTestResultEntries ) );
  }

  @Override public RuntimeTestResultEntry getOverallStatusEntry() {
    return rollupTestResultEntry;
  }

  @Override public List<RuntimeTestResultEntry> getRuntimeTestResultEntries() {
    return runtimeTestResultEntries;
  }

  //OperatorWrap isn't helpful for autogenerated methods
  //CHECKSTYLE:OperatorWrap:OFF
  @Override public String toString() {
    return "RuntimeTestResultSummaryImpl{" +
      "rollupTestResultEntry=" + rollupTestResultEntry +
      ", runtimeTestResultEntries=" + runtimeTestResultEntries +
      '}';
  }
  //CHECKSTYLE:OperatorWrap:OFF
}
